home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Aminet 4
/
Aminet 4 - November 1994.iso
/
aminet
/
dev
/
obero
/
oberon_lib.lha
/
oberon-a
/
source1.lha
/
source
/
Amiga
/
DiskFont.mod
< prev
next >
Wrap
Text File
|
1994-08-08
|
22KB
|
589 lines
(***************************************************************************
$RCSfile: DiskFont.mod $
Description: Interface to diskfont.library
Created by: fjc (Frank Copeland)
$Revision: 3.2 $
$Author: fjc $
$Date: 1994/08/08 01:09:10 $
Includes Release 40.15
(C) Copyright 1985-1993 Commodore-Amiga, Inc.
All Rights Reserved
Oberon-A interface Copyright © 1994, Frank Copeland.
This file is part of the Oberon-A Interface.
See Oberon-A.doc for conditions of use and distribution.
***************************************************************************)
MODULE DiskFont;
(*
** $C- CaseChk $I- IndexChk $L+ LongAdr $N- NilChk
** $P- PortableCode $R- RangeChk $S- StackChk $T- TypeChk
** $V- OvflChk $Z- ZeroVars
*)
IMPORT
E := Exec, D := Dos, U := Utility, G := Graphics, SYS := SYSTEM;
(*
** $VER: diskfont.h 38.0 (18.6.92)
**
** diskfont library definitions
**
** (C) Copyright 1990 Robert R. Burns
** All Rights Reserved
*)
CONST
maxFontPath * = 256; (* including null terminator *)
TYPE
FontContentsPtr * = CPOINTER TO FontContents;
FontContents * = RECORD
fileName * : ARRAY maxFontPath OF CHAR;
ySize * : E.UWORD;
style * : E.BSET;
flags * : E.BSET;
END; (* FontContents *)
TFontContentsPtr * = CPOINTER TO TFontContents;
TFontContents * = RECORD
fileName * : ARRAY maxFontPath - 2 OF CHAR;
tagCount * : E.UWORD; (* including the tagDONE tag *)
(*
* if tagCount is non-zero, fileName is overlayed with
* Text Tags starting at: SYS.VAL (U.TagItemPtr,
* SYS.ADR (fileName[maxFontPath-(tagCount*SIZE (U.TagItem))]))
*)
ySize * : E.UWORD;
style * : E.BSET;
flags * : E.BSET;
END; (* TFontContents *)
CONST
fchId * = 0F00H; (* FontContentsHeader, then FontContents *)
tfchId * = 0F02H; (* FontContentsHeader, then TFontContents *)
ofchId * = 0F03H; (* FontContentsHeader, then TFontContents,
* associated with outline font *)
TYPE
FontContentsHeaderPtr * = CPOINTER TO FontContentsHeader;
FontContentsHeader * = RECORD
fileID * : E.UWORD; (* fchID *)
numEntries * : E.UWORD; (* the number of FontContents elements *)
(**fc * : ARRAY numEntries OF FontContents or
tfc * : ARRAY numEntries OF TFontContents *)
END; (* FontContentsHeader *)
CONST
dfhId * = 0F80H;
maxFontName * = 32; (* font name including ".font\0" *)
TYPE
DiskFontHeaderPtr * = CPOINTER TO DiskFontHeader;
(* the following 8 bytes are not actually considered a part of the *)
(* DiskFontHeader, but immediately preceed it. The nextSegment is *)
(* supplied by the linker/loader, and the returnCode is the code *)
(* at the beginning of the font in case someone runs it... *)
(* nextSegment : E.ULONG; (* actually a BPTR *) *)
(* returnCode : E.ULONG; (* MOVEQ #0,D0 : RTS *) *)
(* here then is the official start of the DiskFontHeader... *)
DiskFontHeader * = RECORD (E.Node) (* node to link disk fonts *)
fileID * : E.UWORD; (* dfhID *)
revision * : E.UWORD; (* the font revision *)
segment * : SYS.BPTR; (* the segment address when loaded *)
dfhName * : ARRAY maxFontName OF CHAR; (* the font name (null terminated) *)
tf * : G.TextFont; (* loaded TextFont structure *)
END; (* DiskFontHeader *)
(* unfortunately, this needs to be explicitly typed *)
(* used only if tf.tfStyle fsTagged bit is set *)
(* DiskFontHeader.tagList = DiskFontHeader.segment; (* destroyed during loading *)*)
CONST
afMemory * = 0;
afDisk * = 1;
afScaled * = 2;
afBitmap * = 3;
afTagged * = 16; (* return TAvailFonts *)
TYPE
AvailFontPtr * = CPOINTER TO AvailFont;
AvailFont * = RECORD
type * : E.WSET; (* MEMORY, DISK, or SCALED *)
attr * : G.TextAttr; (* text attributes for font *)
END; (* AvailFont *)
TAvailFontPtr * = CPOINTER TO TAvailFont;
TAvailFont * = RECORD
Type * : E.WSET; (* MEMORY, DISK, or SCALED *)
Attr * : G.TTextAttr; (* text attributes for font *)
END; (* TAvailFont *)
AvailFontsHeaderPtr * = CPOINTER TO AvailFontsHeader;
AvailFontsHeader * = RECORD
numEntries * : E.UWORD; (* number of AvailFonts elements *)
(**af * : ARRAY numEntries OF AvailFont or
taf * : ARRAY numEntries OF TAvailFont*)
END; (* AvailFontsHeader *)
(*
** $VER: diskfonttag.h 10.4 (14.7.92)
**
** libraries/diskfonttag.h -- tag definitions for .otag files
**
** (C) Copyright 1990-1992 Robert R. Burns
** All Rights Reserved
*)
CONST
(* Level 0 entries never appear in the .otag tag list, but appear in font
* specifications *)
otLevel0 * = U.tagUser;
(* Level 1 entries are required to exist in the .otag tag list *)
otLevel1 * = U.tagUser + 1000H;
(* Level 2 entries are optional typeface metric tags *)
otLevel2 * = U.tagUser + 2000H;
(* Level 3 entries are required for some otEngines *)
otLevel3 * = U.tagUser + 3000H;
(* Indirect entries are at (tag address + data offset) *)
otIndirect * = 8000H;
(********************************************************************)
(* font specification and inquiry tags *)
(* ! tags flagged with an exclaimation mark are valid for
* specification.
* ? tags flagged with a question mark are valid for inquiry
*
* fixed binary numbers are encoded as 16 bits of integer and
* 16 bits of fraction. Negative values are indicated by twos
* complement of all 32 bits.
*)
(* ! otDeviceDPI specifies the target device dots per inch -- X DPI is
* in the high word, Y DPI in the low word. *)
otDeviceDPI * = otLevel0 + 01H; (* == taDeviceDPI *)
(* ! OT_Dot_Size specifies the target device dot size as a percent of
* it's resolution-implied size -- X percent in high word, Y percent
* in low word. *)
otDotSize * = otLevel0 + 02H;
(* ! OT_Point_Height specifies the requested point height of a typeface,
* specifically, the height and nominal width of the em-square.
* The point referred to here is 1/72". It is encoded as a fixed
* binary number. *)
otPointHeight * = otLevel0 + 08H;
(* ! otSetFactor specifies the requested set width of a typeface.
* It distorts the width of the em-square from that specified by
* otPointHeight. To compensate for a device with different
* horizontal and vertical resolutions, otDeviceDpi should be used
* instead. For a normal aspect ratio, set to 1.0 (encoded as
* 0x00010000). This is the default value. *)
otSetFactor * = otLevel0 + 09H;
(* ! otShear... specifies the Sine and Cosine of the vertical stroke
* angle, as two fixed point binary fractions. Both must be specified:
* first the Sine and then the Cosine. Setting the sine component
* changes the Shear to an undefined value, setting the cosine
* component completes the Shear change to the new composite value.
* For no shear, set to 0.0, 1.0 (encoded as 0x00000000, 0x00010000).
* This is the default value. *)
otShearSin * = otLevel0 + 0AH;
otShearCos * = otLevel0 + 0BH;
(* ! otRotate... specifies the Sine and Cosine of the baselin rotation
* angle, as two fixed point binary fractions. Both must be specified:
* first the Sine and then the Cosine. Setting the sine component
* changes the Shear to an undefined value, setting the cosine
* component completes the Shear change to the new composite value.
* For no shear, set to 0.0, 1.0 (encoded as 0x00000000, 0x00010000).
* This is the default value. *)
otRotateSin * = otLevel0 + 0CH;
otRotateCos * = otLevel0 + 0DH;
(* ! otEmbolden... specifies values to algorithimically embolden -- or,
* when negative, lighten -- the glyph. It is encoded as a fixed point
* binary fraction of the em-square. The X and Y components can be
* changed indendently. For normal characters, set to 0.0, 0.0
* (encoded as 0x00000000, 0x00000000). This is the default value. *)
otEmboldenX * = otLevel0 + 0EH;
otEmboldenY * = otLevel0 + 0FH;
(* ! otPointSize is an old method of specifying the point size,
* encoded as (points * 16). *)
otPointSize * = otLevel0 + 10H;
(* ! otGlyphCode specifies the glyph (character) code to use with
* subsequent operations. For example, this is the code for an
* otGlyph inquiry *)
otGlyphCode * = otLevel0 + 11H;
(* ! otGlyphCode2 specifies the second glyph code. For example,
* this is the right glyph of the two glyphs of an otKernPair
* inquiry *)
otGlyphCode2 * = otLevel0 + 12H;
(* ! otGlyphWidth specifies a specific width for a glyph.
* It sets a specific escapement (advance) width for subsequent
* glyphs. It is encoded as a fixed binary fraction of the em-square.
* To revert to using the font-defined escapement for each glyph, set
* to 0.0 (encoded as 0x00000000). This is the default value. *)
otGlyphWidth * = otLevel0 + 13H;
(* ! otOTagPath and
* ! otOTagList specify the selected typeface. Both must be specified:
* first the Path and then the List. Setting the path name changes
* changes the typeface to an undefined value, providing the List
* completes the typeface selection to the new typeface. OTagPath
* is the null terminated full file path of the .otag file associated
* with the typeface. OTagList is a memory copy of the processed
* contents of that .otag file (i.e. with indirections resolved).
* There are no default values for the typeface. *)
otOTagPath * = otLevel0 + otIndirect + 14H;
otOTagList * = otLevel0 + otIndirect + 15H;
(* ? otGlyphMap supplies a read-only struct GlyphMap pointer that
* describes a bitmap for a glyph with the current attributes. *)
otGlyphMap * = otLevel0 + otIndirect + 20H;
(* ? otWidthList supplies a read-only struct MinList of struct
* GlyphWidthEntry nodes for glyphs that are defined from GlyphCode
* to GlyphCode2, inclusive. The widths are represented as fixed
* binary fractions of the em-square, ignoring any effect of
* SetFactor or GlyphWidth. A width would need to be converted to
* a distance along the baseline in device units by the
* application. *)
otWidthList * = otLevel0 + otIndirect + 21H;
(* ? ot...KernPair supplies the kern adjustment to be added to the
* current position after placement of the GlyphCode glyph and
* before placement of the GlyphCode2 glyph. Text kern pairs are
* for rendering body text. Display kern pairs are generally
* tighter values for display (e.g. headline) purposes. The
* adjustment is represented as a fixed binary fraction of the
* em-square, ignoring any effect of SetFactor. This number would
* need to be converted to a distance along the baseline in device
* units by the application. *)
otTextKernPair * = otLevel0 + otIndirect + 22H;
otDesignKernPair * = otLevel0 + otIndirect + 23H;
(* ? otUnderlined is an unsigned word which is used to request
* algorithimic underlining for the engine when rendering the glyph.
* Bullet.library currently does not support this tag, though it
* may be used by other engines in the future. The default for
* any engine which supports this tag must be otulNone. Engines which
* do not support this tag should return an appropriate otErr value.
*
* As of V39, diskfont.library will request underlining if specified
* in the TextAttr, or TTextAttr passed to OpenDiskFont(). Diskfont
* will first request Broken underlining (like the Text() function
* does when SetSoftStyle() is used), and then Solid underlining if
* the engine returns an error. If the engine returns an error for
* both, then diskfont.library attempts to find, or create the best
* non-underlined font that it can. *)
otUnderLined * = otLevel0 + 24H;
otulNone * = 0;
otulSolid * = 1;
otulBroken * = 2;
otulDoubleSolid * = 3;
outlDoubleBroken * = 4;
(* ? otStrikeThrough is a boolean which is used to request
* algorithimic strike through when rendering the glyph.
* Bullet.library currently does not support this tag, though it
* may be used by other engines in the future. The default for
* any engined which supports this tag must be FALSE. Engines which
* do not support this tag should return an appropriate otErr value. *)
otStrikeThrough * = otLevel0 + 25H;
(********************************************************************)
(* .otag tags *)
(* suffix for files in FONTS: that contain these tags *)
otSuffix * = ".otag";
(* otFileIdent both identifies this file and verifies its size.
* It is required to be the first tag in the file. *)
otFileIdent * = otLevel1 + 01H;
(* otEngine specifies the font engine this file is designed to use *)
otEngine * = otLevel1 + otIndirect + 02H;
oteBullet * = "bullet";
(* otFamily is the family name of this typeface *)
otFamily * = otLevel1 + otIndirect + 03H;
(* The name of this typeface is implicit in the name of the .otag file *)
(* otBName is used to find the bold variant of this typeface *)
otBName * = otLevel2 + otIndirect + 05H;
(* otIName is used to find the italic variant of this typeface *)
otIName * = otLevel2 + otIndirect + 06H;
(* otBIName is used to find the bold italic variant of this typeface *)
otBIName * = otLevel2 + otIndirect + 07H;
(* otSymSet is used to select the symbol set that has the otYSizeFactor
* described here. Other symbol sets might have different extremes *)
otSymbolSet * = otLevel1 + 10H;
(* otYSizeFactor is a ratio to assist in calculating the Point height
* to BlackHeight relationship -- high word: Point height term, low
* word: Black height term -- pointSize * = ysize*<high>/<low> *)
otYSizeFactor * = otLevel1 + 11H;
(* otSpaceWidth specifies the width of the space character relative
* to the character height *)
otSpaceWidth * = otLevel2 + 12H;
(* otIsFixed is a boolean indicating that all the characters in the
* typeface are intended to have the same character advance *)
otIsFixed * = otLevel2 + 13H;
(* otSerifFlag is a boolean indicating if the character has serifs *)
otSerifFlag * = otLevel1 + 14H;
(* otStemWeight is an unsigned byte indicating the weight of the character *)
otStemWeight * = otLevel1 + 15H;
otsUltraThin * = 8; (* 0- 15 *)
otsExtraThin * = 24; (* 16- 31 *)
otsThin * = 40; (* 32- 47 *)
otsExtraLight * = 56; (* 48- 63 *)
otsLight * = 72; (* 64- 79 *)
otsDemiLight * = 88; (* 80- 95 *)
otsSemiLight * = 104; (* 96-111 *)
otsBook * = 120; (* 112-127 *)
otsMedium * = 136; (* 128-143 *)
otsSemiBold * = 152; (* 144-159 *)
otsDemiBold * = 168; (* 160-175 *)
otsBold * = 184; (* 176-191 *)
otsExtraBold * = 200; (* 192-207 *)
otsBlack * = 216; (* 208-223 *)
otsExtraBlack * = 232; (* 224-239 *)
otsUltraBlack * = 248; (* 240-255 *)
(* otSlantStyle is an unsigned byte indicating the font posture *)
otSlantStyle * = otLevel1 + 16H;
otsUpright * = 0;
otsItalic * = 1; (* Oblique, Slanted, etc. *)
otsLeftItalic * = 2; (* Reverse Slant *)
(* otHorizStyle is an unsigned byte indicating the appearance width *)
otHorizStyle * = otLevel1 + 17H;
othUltraCompressed * = 16; (* 0- 31 *)
othExtraCompressed * = 48; (* 32- 63 *)
othCompressed * = 80; (* 64- 95 *)
othCondensed * = 112; (* 96-127 *)
othNormal * = 144; (* 128-159 *)
othSemiExpanded * = 176; (* 160-191 *)
othExpanded * = 208; (* 192-223 *)
othExtraExpanded * = 240; (* 224-255 *)
(* otSpaceFactor specifies the width of the space character relative
* to the character height *)
otSpaceFactor * = otLevel2 + 18H;
(* otInhibitAlgoStyle indicates which style bits, if any, should
* be ignored even if the font does not already have that quality.
* For example, if fsBold is set and the typeface is not bold but
* the user specifies bold, the application or diskfont library is
* not to use otEmbolden to achieve a bold result. *)
otInhibitAlgoStyle * = otLevel2 + 19H;
(* otAvailSizes is an indirect pointer to sorted UWORDs, 0th is count *)
otAvailSizes * = otLevel1 + otIndirect + 20H;
otMaxAvailSizes * = 20; (* no more than 20 sizes allowed *)
(* otSpecCount is the count number of parameters specified here *)
otSpecCount * = otLevel1 + 100H;
(* otSpecs can be created as appropriate for the engine by ORing in the
* parameter number (1 is first, 2 is second, ... up to 15th) *)
otSpec * = otLevel1 + 100H;
(* otSpec1 is the (first) parameter to the font engine to select
* this particular typeface *)
otSpec1 * = otLevel1 + 101H;
(*
** $VER: glyph.h 9.1 (19.6.92)
**
** glyph.h -- structures for glyph libraries
**
** (C) Copyright 1991-1992 Robert R. Burns
** All Rights Reserved
*)
TYPE
(* A GlyphEngine must be acquired via OpenEngine and is read-only *)
GlyphEnginePtr * = CPOINTER TO GlyphEngine;
GlyphEngine * = RECORD
library * : E.LibraryPtr; (* engine library *)
name * : E.STRPTR; (* library basename: e.g. "bullet" *)
(* private library data follows... *)
END;
FIXED * = LONGINT; (* 32 bit signed w/ 16 bits of fraction *)
GlyphMapPtr * = CPOINTER TO GlyphMap;
GlyphMap * = RECORD
bmModulo * : E.UWORD; (* # of bytes in row: always multiple of 4 *)
bmRows * : E.UWORD; (* # of rows in bitmap *)
blackLeft * : E.UWORD; (* # of blank pixel columns at left *)
blackTop * : E.UWORD; (* # of blank rows at top *)
blackWidth * : E.UWORD; (* span of contiguous non-blank columns *)
blackHeight * : E.UWORD; (* span of contiguous non-blank rows *)
xOrigin * : FIXED; (* distance from upper left corner of bitmap *)
yOrigin * : FIXED; (* to initial CP, in fractional pixels *)
x0 * : INTEGER; (* approximation of XOrigin in whole pixels *)
y0 * : INTEGER; (* approximation of YOrigin in whole pixels *)
x1 * : INTEGER; (* approximation of XOrigin + Width *)
y1 * : INTEGER; (* approximation of YOrigin + Width *)
width * : FIXED; (* character advance, as fraction of em width *)
bitMap * : E.APTR; (* actual glyph bitmap *)
END;
GlyphWidthEntryPtr * = CPOINTER TO GlyphWidthEntry;
GlyphWidthEntry * = RECORD (E.MinNode)
(* on list returned by otWidthList inquiry *)
code * : E.UWORD; (* entry's character code value *)
width * : FIXED; (* character advance, as fraction of em width *)
END;
(*
** $VER: oterrors.h 8.1 (19.6.92)
**
** oterrors.h -- error results from outline libraries
**
** (C) Copyright 1991-1992 Robert R. Burns
** All Rights Reserved
*)
CONST
(* PRELIMINARY *)
otErrFailure * = -1; (* catch-all for error *)
otErrSuccess * = 0; (* no error *)
otErrBadTag * = 1; (* inappropriate tag for function *)
otErrUnknownTag * = 2; (* unknown tag for function *)
otErrBadData * = 3; (* catch-all for bad tag data *)
otErrNoMemory * = 4; (* insufficient memory for operation *)
otErrNoFace * = 5; (* no typeface currently specified *)
otErrBadFace * = 6; (* typeface specification problem *)
otErrNoGlyph * = 7; (* no glyph specified *)
otErrBadGlyph * = 8; (* bad glyph code or glyph range *)
otErrNoShear * = 9; (* shear only partially specified *)
otErrNoRotate * = 10; (* rotate only partially specified *)
otErrTooSmall * = 11; (* typeface metrics yield tiny glyphs *)
otErrUnknownGlyph * = 12; (* glyph not known by engine *)
(**-- Library Base variable --------------------------------------------*)
TYPE
DiskFontBasePtr * = CPOINTER TO DiskFontBase;
DiskFontBase * = RECORD (E.Library) END;
CONST
name * = "diskfont.library";
VAR
base * : DiskFontBasePtr;
(**-- Library Functions ------------------------------------------------*)
(*
** $VER: diskfont_protos.h 38.0 (18.6.92)
*)
LIBCALL (base : DiskFontBasePtr) OpenDiskFont*
( VAR textAttr [8] : G.TextAttr )
: G.TextFontPtr;
-30;
LIBCALL (base : DiskFontBasePtr) AvailFonts*
( VAR buffer [8] : ARRAY OF SYS.BYTE;
bufBytes [0] : LONGINT;
flags [1] : SET )
: LONGINT;
-36;
(* --- functions in V34 or higher (distributed as Release 1.3) ---*)
LIBCALL (base : DiskFontBasePtr) NewFontContents*
( fontsLock [8] : D.FileLockPtr;
fontName [9] : ARRAY OF CHAR )
: FontContentsHeaderPtr;
-42;
LIBCALL (base : DiskFontBasePtr) DisposeFontContents*
( fontContentsHeader [9] : FontContentsHeaderPtr );
-48;
(* --- functions in V36 or higher (distributed as Release 2.0) ---*)
LIBCALL (base : DiskFontBasePtr) NewScaledDiskFont*
( sourceFont [8] : G.TextFontPtr;
VAR destTextAttr [9] : G.TextAttr )
: DiskFontHeaderPtr;
-54;
(**-- Library Base variable --------------------------------------------*)
(** $L- Address globals through A4 *)
(**-----------------------------------*)
PROCEDURE* CloseLib ();
BEGIN (* CloseLib *)
IF base # NIL THEN E.base.CloseLibrary (base) END;
END CloseLib;
(**-----------------------------------*)
PROCEDURE OpenLib * (mustOpen : BOOLEAN);
BEGIN (* OpenLib *)
IF base = NIL THEN
base :=
SYS.VAL
( DiskFontBasePtr,
E.base.OpenLibrary (name, E.libraryMinimum));
IF base # NIL THEN SYS.SETCLEANUP (CloseLib)
ELSIF mustOpen THEN HALT (100)
END;
END;
END OpenLib;
BEGIN
base := NIL
END DiskFont.